import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import javax.swing.table.*;
import javax.swing.UIManager;
import javax.swing.ImageIcon;

class PreviewRenderer extends DefaultTableCellRenderer{
  public Component getTableCellRendererComponent(JTable tblDataTable, 
                                                 Object value, boolean isSelected, 
                                                 boolean hasFocus, int markedRow, int col){
    JLabel ret=(JLabel)super.getTableCellRendererComponent(tblDataTable,
                                                           value,isSelected,
                                                           hasFocus,markedRow,col);
    ret.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    DBFile dbf = new DBFile(value.toString());         
    if (dbf.getFlavor() == ExtensionKeys.PICTURENAME) {
      ImageIcon imageicon_orig = new ImageIcon(value.toString());
      Image image = imageicon_orig.getImage();
      Image image_scaled = image.getScaledInstance( 50, 50, Image.SCALE_FAST);
      ImageIcon imageicon_scaled = new ImageIcon(image_scaled);
      setText("");
      setIcon(imageicon_scaled);
    }
    else {
      setText(dbf.getName());
      setIcon(null);
    }
    setHorizontalAlignment(JLabel.CENTER);
    return ret;
  }
}